// Learn cc.Class:
//  - [Chinese] http://www.cocos.com/docs/creator/scripting/class.html
//  - [English] http://www.cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/class/index.html
// Learn Attribute:
//  - [Chinese] http://www.cocos.com/docs/creator/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/reference/attributes/index.html
// Learn life-cycle callbacks:
//  - [Chinese] http://www.cocos.com/docs/creator/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/life-cycle-callbacks/index.html

/**
* 公告详情界面
*/
cc.Class({
    extends: cc.Component,

    properties: {
        labNoticeTitle: cc.Label,  //内容标题
        labDate: cc.Label,    //日期
        labTime: cc.Label,    //时间
        wbView: cc.WebView,  //内容详情 

    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    init: function(data){
        //显示内容
        this.labNoticeTitle.string = data.Title;
        //cc.log('data.LookUrl',data.LookUrl,this.wbView);
        this.wbView._url = data.LookUrl;

        var date =Utils.formateServiceDateStrToDate(data.Time);
        this.labDate.string = this.splitTwo(date.getFullYear())+'-'+this.splitTwo(date.getMonth() + 1)+'-'+ this.splitTwo(date.getDate());    
        this.labTime.string = this.splitTwo(date.getHours())+'-'+this.splitTwo(date.getMinutes())+'-'+ this.splitTwo(date.getSeconds());
      
    },

    splitTwo:function(num){
        return num.toString().length<2?"0"+num.toString():num.toString();
    },

    onClose: function(){
        this.node.getComponent("Page").backAndRemove();
    },

    // update (dt) {},
});
